<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

require dirname(__FILE__).'/pc_controller.php';

class Hd_invitation_quanity_rank extends PC_controller {

    public function __construct(){
        parent::__construct();
        $this->load->model('Hdinvitationreadingquanitymodel','m_reading_quanity');
    }

    public function index(){
        $data = parent::index();
        $this->load->view('admin/hd_invitation_quanity_rank',$data);
    }

    public function getReadingQuanityList() {
        $assist['where'] = getFilter($this->input->post(),Hdinvitationreadingquanitymodel::$searchField);
        $assist['like'] = getFilter($this->input->post(),Hdinvitationreadingquanitymodel::$likeField);
        $assist['pagination'] = getPagination($this->input->post());

        $assist['select'] = '
            user.user_name,
            hd_invitation_lottery_history.*
        ';
        list($list,$count) = $this->m_reading_quanity->getReadingQuanityListSection($assist);
        foreach ($list as $key => $value) {
            $list[$key]['image_path'] = UPLOAD_URL_ORIGIN.$value['image_path'];
        }

        $this->response->setSuccess();
        $this->response->setItems($list);
        $this->response->setTotalCount($count);
        $this->response->responseExit();
    }

    public function updateQuanity() {
        $this->validate->setRule('user_id','integer');
        $this->validate->setRule('quanity','integer');
        if(!$this->validate->run($this->input->post())){
            $this->response->setDetail($this->validate->getMessage());
            $this->response->responseExit();
        }
        $info = $this->validate->getResult();

        $info['reading_quanity_time_create'] = NOW;
        $this->m_reading_quanity->updateReadingQuanity($info);
        $this->m_reading_quanity->updateReadingQuanityRankList();

        $this->response->setSuccess();
        $this->response->responseExit();
    }

}
/* End of file aa_game_history.php */
/* Location: ./application/controllers/aa_game_history.php */
